def partition(numbers, number): # DO NOT modify this line 
    # TODO: add your code here
    left = []
    right = []
    for num in numbers:
        if num < number:
            left.append(num)
        else:
            right.append(num)
    index = len(left)
    left.append(number)
    numbers[:] = left + right
    return index
    return # You can modify or delete this line

# === DO NOT modify the code below ===
def main():
    numbers = [ eval(x) for x in input().split() ]
    x = eval(input())
    index = partition(numbers, x)
    print(" ".join(map(str,numbers)))
    print(index)
    
if __name__ == "__main__":
    main()
# === DO NOT modify the code above ===